import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', () => {
  const user = ref({
     id:null,
     phone:null,
  })
  const isLogin = ref(localStorage.getItem('isLogin'))
  const account = ref()
  function login(form) {
    console.log(form,'user');
    this.user.phone=form.username
    account.value=form.username?.substring(0, 3) + "****" + form.username.substring(7)
    isLogin.value=true
    localStorage.setItem('isLogin', isLogin.value)
  }

  return { account, login, user,isLogin }
},{
  persist: true
})
